<%+header%>
<h2><a id="content" name="content"><%:APdevice attack%></a></h2>
<script>  //general function
	function setValue(ID,val){
		document.getElementById(ID).value=val;	
	}
</script>

<script>
	
//get the URL parameters
function receive(){
    var thisURL=document.URL;
    var recVal=thisURL.split('?');
    if(recVal.length > 1){
        return recVal;	
    }
} 
		 

var buttonStart="<%:start%>";
var buttonStop="<%:stop%>";

function ActStat(val){
	
		 if(buttonStart == val){
		     val="start";	
		 }else if(buttonStop == val){
		     val="stop";	
		 }
		 
        var callPath='<%=luci.dispatcher.build_url("admin", "wifiscan","APAttackAct")%>';
        callPath=callPath+'/'+val+'/'+URLParam[1]+'/'+URLParam[2];
        //callPath=callPath+'/'+val+'/'+URLParam[1]+'/'+URLParam[2]+'/'+URLParam[3]+'/'+URLParam[3];
        XHR.get(callPath,null,function(x,rval){
	
	   	       switch(rval[0])
	   	       { 
	   	       	   case "runing":
	   	           case "stop":
	   	               setValue("ID_INPUT_GetPack",buttonStop);
	   	           break;	
	   	           case "unruning":
	   	           case "start":
	   	               setValue("ID_INPUT_GetPack",buttonStart);
	   	           break;
	   	           default:
	   	               alert("lua action is err!");
	   	           break;
	   	       }
		         //getPackageList();
		     }
	   );
}


var URLParam=new Array();    
function init()
{
	URLParam=receive();
	ActStat("status");	
	//getPackageList();
}
</script>

<p id="ID_P_wait"></p>
<fieldset class="cbi-section">
	<div>
		<input type="button" class="cbi-button" id="ID_INPUT_GetPack" onclick="ActStat(this.value)" value="<%:start%>">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </div>
  <br/>

  <script>init();</script>
</fieldset>
<%+footer%>
